package com.ruoyi.system.service.impl;

import com.ruoyi.system.entity.JobInvolveGasNumberConfig;
import com.ruoyi.system.mapper.JobInvolveGasNumberConfigMapper;
import com.ruoyi.system.service.JobInvolveGasNumberConfigService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 涉及气体位号(JobInvolveGasNumberConfig)表服务实现类
 *
 * @author makejava
 * @since 2022-11-25 11:39:04
 */
@Service("jobInvolveGasNumberConfigService")
public class JobInvolveGasNumberConfigServiceImpl implements JobInvolveGasNumberConfigService {
    @Resource
    private JobInvolveGasNumberConfigMapper jobInvolveGasNumberConfigDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public JobInvolveGasNumberConfig queryById(Integer id) {
        return this.jobInvolveGasNumberConfigDao.queryById(id);
    }

    /**
     * 分页查询
     *
     * @param jobInvolveGasNumberConfig 筛选条件
     * @param pageRequest      分页对象
     * @return 查询结果
     */
    @Override
    public Page<JobInvolveGasNumberConfig> queryByPage(JobInvolveGasNumberConfig jobInvolveGasNumberConfig, PageRequest pageRequest) {
        long total = this.jobInvolveGasNumberConfigDao.count(jobInvolveGasNumberConfig);
        return new PageImpl<>(this.jobInvolveGasNumberConfigDao.queryAllByLimit(jobInvolveGasNumberConfig, pageRequest), pageRequest, total);
    }

    @Override
    public List<JobInvolveGasNumberConfig> queryAll(JobInvolveGasNumberConfig jobInvolveGasNumberConfig) {
        return jobInvolveGasNumberConfigDao.queryAll(jobInvolveGasNumberConfig);
    }

    /**
     * 新增数据
     *
     * @param jobInvolveGasNumberConfig 实例对象
     * @return 实例对象
     */
    @Override
    public JobInvolveGasNumberConfig insert(JobInvolveGasNumberConfig jobInvolveGasNumberConfig) {
        this.jobInvolveGasNumberConfigDao.insert(jobInvolveGasNumberConfig);
        return jobInvolveGasNumberConfig;
    }

    /**
     * 修改数据
     *
     * @param jobInvolveGasNumberConfig 实例对象
     * @return 实例对象
     */
    @Override
    public JobInvolveGasNumberConfig update(JobInvolveGasNumberConfig jobInvolveGasNumberConfig) {
        this.jobInvolveGasNumberConfigDao.update(jobInvolveGasNumberConfig);
        return this.queryById(jobInvolveGasNumberConfig.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer id) {
        return this.jobInvolveGasNumberConfigDao.deleteById(id) > 0;
    }
}
